﻿@model LbangCMS.ViewModels.IndexProductListModel
@{
    ViewBag.Title = "产品展示";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@{ Html.RenderPartial("_InnerBanner");}

<div class="gx_p_content container">
    <div class="row">
        <div class="gx_p_content_left am-animation-slide-left" data-am-scrollspy="{animation: 'slide-left'}">
            <div class="gx_p_left_top hidden-in"><h2 class="gx_p_left_tittle">产品展示</h2><span class="gx_p_left_letter">PRODUCT</span></div>
            <ul class="gx_p_left_nav clearfix">
                @if (Model.Categories != null && Model.Categories.Any())
                {
                    foreach (var item in Model.Categories)
                    {
                        if (item.ID == Model.CurrentCategoryId)
                        {
                            <li><a class="gx_p_nav_on" href="#">@item.Name<i class="fa icon-left hidden-in"></i></a></li>
                        }
                        else
                        {
                            <li><a href="@Url.Action("Index","Product",new { categoryId=item.ID})">@item.Name<i class="fa icon-left hidden-in"></i></a></li>
                        }
                    }
                }
            </ul>
        </div>
    </div>
    <div class="gx_p_content_right am-animation-scale-up" data-am-scrollspy="{animation: 'scale-up'}">
        <div class="gx_p_right_top">
            <div class="gx_p_right_title">
                <strong class="gx_p_right_name">@Model.CurrentCategoryName</strong><span class="gx_p_right_letter"><i class="fa icon_small"></i></span>
            </div>
            <div class="gx_p_right_position hidden-in">
                <i class="fa icon-position"></i><a href="@Url.Action("Index","Home")">首页</a>><a href="@Url.Action("Index","Product",new { categoryId=Model.CurrentCategoryId })">@Model.CurrentCategoryName</a>
            </div>
        </div>
        <div class="gx_p_right_main">
            @if (Model.Products != null && Model.Products.Any())
            {
                    <ul class="gx_p_product_all clearfix">
                    @foreach (var item in Model.Products)
                    {
                        <li class="middles-4 min-6" data-am-scrollspy="{animation: 'fade'}"><div class="gx_p_product_list"><a class="gx_p_product_img" href="@Url.Action("Detail","Product",new { ID=item.ID})"><img src="@item.ImageSrc" alt="" /></a><a class="gx_p_product_text" href="@Url.Action("Detail","Product",new { ID=item.ID})">@item.Name</a></div></li>
                                                                                                                                                                                                                                                        }
                    </ul>
                    <div id="pager" class="gx_p_right_more hidden-in" data-am-scrollspy="{animation: 'fade'}">

                    </div>
                    <div class="gx_p_right_more hidden-lg" data-am-scrollspy="{animation: 'fade'}"><a class="gx_p_right_more_on" href="@Url.Action("Index", "Product", new { categoryId = ViewBag.CategoryId, pageIndex = Model.CurrentPageIndex + 1, pageSize = (Model.CurrentPageIndex + 1) * 5 })">查看更多>></a></div>
            }
</div>
    </div>
</div>
@section script{
    <script src="~/Content/laypage/laypage.js"></script>
    <script>
        var totalPage=@Model.TotalPage
        laypage({
            cont: 'pager',
            pages: totalPage, //可以叫服务端把总页数放在某一个隐藏域，再获取。假设我们获取到的是18
            curr: function () { //通过url获取当前页，也可以同上（pages）方式获取
                var page = location.search.match(/pageIndex=(\d+)/);
                return page ? page[1] : 1;
            }(),
            jump: function (e, first) { //触发分页后的回调
                if (!first) { //一定要加此判断，否则初始时会无限刷新
                    location.href = '?pageIndex=' + e.curr;
                }
            }
        });
    </script>
}

